﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Clothes.Items.ModuleData;
using ApplicationLibrary;

namespace Clothes.Items.Libraries
{
    public partial class CategoriesTreeForm : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        public string Code { get; set;}

        public CategoriesTreeForm()
        {
            InitializeComponent();

            if ((LicenseManager.UsageMode == LicenseUsageMode.Designtime))
                return;
        }

        protected override void OnShown(System.EventArgs e)
        {
            base.OnShown(e);
            trvCat.LoadCategories();
            if (!Code.IsEmpty())
            {
                TreeNode node = trvCat.FindCurrentCode(Code);
                if (node != null)
                    trvCat.SelectedNode = node;
                }
        }

        private void trvCat_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            Code = trvCat.CreateCode(trvCat.SelectedNode);
            DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            Code = trvCat.CreateCode(trvCat.SelectedNode);
        }
    }
}
